'use strict'

define(['jquery', 'bootstrap', 'select2', 'shiftform', 'validate', 'validate.en', 'datetimepicker', 'datetimepickerCN'], function($) {
  
  return {
        
    init: function() {
        this.initCreate();
        this.initDelete();
        this.initView();
    },
    
    initCreate: function(){
        $(document).on("shown.bs.modal", "#create", function(e) {
            var $form = $(e.currentTarget).find("form");
            
            $form.bt_validate();
            
            $form.shiftform({
                beforeSubmit: function(el) {
                      $('form').trigger("validate.ajax.submit");
                      return $.bt_validate.result[$.bt_validate.form_id]
                    }
            });
        })
             
    },
    
    initDelete: function(){
        $(document).on("shown.bs.modal", "#delete", function(e) {
            var $form = $(e.currentTarget).find("form");
            
            $form.shiftform();
        })
             
    },
    
    initView: function(){
        $(document).on("shown.bs.modal", "#view", function(e) {
            var $form = $(e.currentTarget).find("form");
            
            $form.shiftform();
        })
             
    },
        
      
   }
})
